import request from '@/utils/request'

/**
 * 商品收藏
 * @param {String} page - 当前页
 * @param {String} limit - 页条数
 * @returns Promise
 */
export const getCoollList = (page, limit = 10) => {
  return request('/api/goods/collList', 'get', { page, limit })
}

/**
 * 优惠卷
 * @param {*} activeState 空 就是全部 wait_use-未使用 used-已使用 invalid-已过期
 * @returns
 */
export const getCoupon = (activeState = '') => {
  return request('/api/coupon/myCoupon', 'get', { activeState })
}

/**
 * 足迹
 * @param {String} page 当前页
 * @param {String} limit 也条数
 * @returns
 */
export const getBrowsingHistory = (page, limit) => {
  return request('/api/goods/goods_footprint', 'get', { page, limit })
}

/**
 * 清空足迹
 * @returns 
 */
export const deleteGoodsFootprint = () => {
  return request('/api/goods/delete_goods_footprint', 'post')
}

/**
 * 积分明细
 * @returns
 */
export const getScoreLogs = () => {
  return request('/api/user/scoreLogs', 'get')
}

/**
 * 签到
 * @returns
 */
export const userSign = () => {
  return request('/api/user/sign', 'get')
}

/**
 * 获取我订单
 * @param {String} activeState all-全部 cancel-取消 wait_pay-代付款 send-待发货 receive-已发货 completed-已完成 refund-售后
 * @returns
 */
export const getUserOrder = (activeState) => {
  return request('/api/order/lists', 'get', { activeState })
}

/**
 * 取消订单
 * @param {String} id 订单id
 * @returns
 */
export const caneclOrder = (id) => {
  return request('/api/order/cancel', 'post', { id })
}

/**
 * 确认收货
 * @param {String} id 订单id
 * @returns
 */
export const confirmReceive = (id) => {
  return request('/api/order/receive', 'post', { id })
}

/**
 * 评价商品
 * @param {*} data cond_id-商品id content-评价内容 img-图片 level-评分 logistics_level-物流评价 send_level-发货评价 service_level服务评价 describe_level-货描 评价
 * @returns
 */
export const commentGoods = (data) => {
  return request('/api/order/comment', 'post', data)
}

/**
 * 获取已经评价列表
 * @returns
 */
export const commentList = () => {
  return request('/api/order/comment_list', 'get')
}

/**
 * 钱包 & 明细
 * @returns
 */
export const getMoneyLogs = () => {
  return request('/api/user/moneyLogs', 'get')
}

/**
 * 获取发票管理
 * @returns
 */
export const invoice = () => {
  return request('/api/user/invoice', 'get')
}

/**
 * 发票编辑 and 新增
 * @returns
 */
export const invoiceDdit = (data) => {
  return request('/api/user/invoice_edit', 'post', data)
}

export const invoiceDel = (id) => {
  return request('/api/user/invoice_delete', 'get', { id })
}

/**
 * 新增询价
 * @param {*} data
 * @returns
 */
export const inquiryOrder = (data) => {
  return request('/api/user/inquiry_order', 'post', data)
}

/**
 * 询价列表
 * @returns
 */
export const inquiryOrderList = () => {
  return request('/api/user/inquiry_order_list', 'get')
}

/**
 * 充值
 * @param {*} money 充值金额
 * @returns
 */
export const recharge = (money) => {
  return request('/api/order/recharge', 'post', { money })
}


export default {
  getCoupon,
  getCoollList,
  getBrowsingHistory,
  getScoreLogs,
  userSign,
  getUserOrder,
  caneclOrder,
  confirmReceive,
  commentGoods,
  commentList,
  getMoneyLogs,
  invoice,
  invoiceDdit,
  invoiceDel,
  inquiryOrder,
  inquiryOrderList,
  recharge,
  deleteGoodsFootprint
}